'\" te
.\" Copyright (c) 2004, Sun Microsystems, Inc., All Rights Reserved
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH USB_GET_STATUS 9F "Jan 5, 2004"
.SH NAME
usb_get_status \- Get status of a USB device/endpoint/interface
.SH SYNOPSIS
.nf
#include <sys/usb/usba.h>



\fBint\fR \fBusb_get_status\fR(\fBdev_info_t *\fR\fIdip\fR, \fBusb_pipe_handle_t\fR \fIpipe_handle\fR,
     \fBuint_t\fR \fIrequest_type\fR, \fBuint_t\fR \fIwhich\fR, \fBuint16_t *\fR\fIstatus\fR,
     \fBusb_flags_t\fR \fIflags\fR);
.fi

.SH INTERFACE LEVEL
illumos DDI specific (illumos DDI)
.SH PARAMETERS
.ne 2
.na
\fB\fIdip\fR\fR
.ad
.RS 16n
Pointer to device's dev_info structure.
.RE

.sp
.ne 2
.na
\fB\fIpipe_handle\fR\fR
.ad
.RS 16n
Default control pipe handle on which request is made.
.RE

.sp
.ne 2
.na
\fB\fIrequest_type\fR\fR
.ad
.RS 16n
bmRequestType. Either:
.sp
USB_DEV_REQ_RCPT_DEV \(em Get device status.
.sp
USB_DEV_REQ_RCPT_IF \(em Get interface status.
.sp
USB_DEV_REQ_RCPT_EP \(em Get endpoint status.
.RE

.sp
.ne 2
.na
\fB\fIwhich\fR\fR
.ad
.RS 16n
Device, interface or endpoint from which to get status.  Either  number of
interface or endpoint, or  0 if device status requested.
.RE

.sp
.ne 2
.na
\fB\fIstatus\fR\fR
.ad
.RS 16n
Address into which the status is written.
.RE

.sp
.ne 2
.na
\fB\fIflags\fR\fR
.ad
.RS 16n
None are recognized.
.RE

.SH DESCRIPTION
The \fBusb_get_status()\fR function returns the status of a device, interface
or endpoint.  All status requests use the default control pipe. Length of data
returned is USB_GET_STATUS_LEN bytes.  Always block and wait for resources if
not available, regardless of the flags argument.
.sp
.LP
When the \fIrequest_type\fR recipient is USB_DEV_REQ_RCPT_DEV, device status is
requested. Status returned includes bits for USB_DEV_SLF_PWRD_STATUS (device is
currently  self-powered) and USB_DEV_RWAKEUP_STATUS (device has remote  wakeup
enabled). A set bit indicates the corresponding status.
.sp
.LP
When the \fIrequest_type\fR is USB_DEV_REQ_RCPT_EP, endpoint status is
requested. Status returned includes bits for USB_EP_HALT_STATUS (endpoint is
halted). A set bit indicates the corresponding status.
.sp
.LP
When the \fIrequest_type\fR is USB_DEV_REQ_RCPT_IF, interface status is
requested and USB_IF_STATUS (zero) is returned.
.SH RETURN VALUES
.ne 2
.na
\fBUSB_SUCCESS\fR
.ad
.RS 20n
Status returned successfully in the status argument.
.RE

.sp
.ne 2
.na
\fBUSB_INVALID_ARGS\fR
.ad
.RS 20n
Status pointer and/or dip argument is NULL.
.RE

.sp
.ne 2
.na
\fBUSB_INVALID_PIPE\fR
.ad
.RS 20n
Pipe handle is NULL.
.RE

.sp
.ne 2
.na
\fBUSB_FAILURE\fR
.ad
.RS 20n
Status not returned successfully.
.RE

.SH CONTEXT
May be called from user or kernel context.
.SH EXAMPLES
.in +2
.nf
  uint16_t status;

  if (usb_get_status(
      dip, pipe_handle, USB_DEV_REQ_RCPT_DEV, 0 &status, 0) ==
      USB_SUCCESS) {
          if (status & USB_DEV_SLF_PWRD_STATUS) {
                  cmn_err (CE_WARN,
                      "%s%d: USB device is running on its own power.",
                      ddi_driver_name(dip), ddi_get_instance(dip));
          }
  }
.fi
.in -2

.SH ATTRIBUTES
See \fBattributes\fR(7) for descriptions of the following attributes:
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
Architecture	PCI-based systems
_
Interface stability	Committed
.TE

.SH SEE ALSO
\fBattributes\fR(7), \fBusb_clr_feature\fR(9F), \fBusb_get_alt_if\fR(9F),
\fBusb_pipe_get_state\fR(9F), \fBusb_get_cfg\fR(9F),
